<template>
  <div id="actual">
    <div class="one">
      <a-large-screen-group :LeftTitle="LeftTitle[0]" color="now1" :images="IconImg1"
        :grouplist="sssb"></a-large-screen-group>
    </div>
    <div class="two">
      <!-- <div class="btn-box"> -->
      <!-- <el-radio-group v-model="radio1" fill="#ffffff33" text-color="#fff">
          <el-radio-button label="上一小时"></el-radio-button>
          <el-radio-button label="当日"></el-radio-button>
        </el-radio-group>
      </div> -->
      <!-- <template v-if="radio1 == '上一小时'"> -->
      <c-large-screen-group :LeftTitle="LeftTitle[1]" color="now2" :images="IconImg2"
        :grouplist="syxs"></c-large-screen-group>

    </div>
    <div class="three">

      <d-large-screen-group></d-large-screen-group>

      <!-- <el-input v-model="searchQuery" style="width: 30%;font-size: 15px;" type="text" placeholder="请输入企业名称"
          prefix-icon="el-icon-search">
        </el-input> -->

      <!-- <el-tree v-if="filteredEnterprises" :expand-on-click-node="false" :default-expand-all="false"
            :data="filteredEnterprises" :props="defaultProps" style="background-color: transparent;overflow-y: auto;"
            @node-click="handleNodeClick">
            <template v-slot="{ node, data }">
              <div v-if="node.level === 1" class="label">
                 <i :class="{
                  'el-icon-folder': !node.expanded,       // 节点收缩时的图标
                  'el-icon-folder-opened': node.expanded, // 节点展开时的图标
                }" />
                {{ node.label + " (" + data.count + ")" }}
              </div>
              <div v-else-if="node.level === 2" class="label"
                >
                <i class="el-icon-location-information" />
                {{ node.label }}
              </div>

            </template>

</el-tree> -->
      <!-- <div class="tree-container">

        </div> -->


    </div>
  </div>
</template>

<script>
import {

  getCity,
  getCompanyByDistrictCode
} from '@/api/hzMJPT/mainInterface.js';

import ALargeScreenGroup from "@/components/ALargeScreenGroup/ALargeScreenGroup";
import CLargeScreenGroup from "@/components/ALargeScreenGroup/CLargeScreenGroup";
import DLargeScreenGroup from "@/components/ALargeScreenGroup/DLargeScreenGroup";

import {
  getCarLastHourCountCache,
  getCarDayCountsummaryToday,
  enterpriseMonitoringCounts,
} from "@/api/largescreen/index.js";

import IconImg1 from "@/assets/images/now-icon1.svg";
import IconImg2 from "@/assets/images/now-icon2.svg";
import IconImg3 from "@/assets/images/now-icon3.svg";
import { mapState } from "vuex";

let data = [
  { title: "总览", smallTitle: "电子围栏（总数）" },
  { title: "区县企业分布", smallTitle: "上一小时（辆）" },
];
export default {
  name: "MapLeft",
  components: {
    ALargeScreenGroup,
    CLargeScreenGroup,
    DLargeScreenGroup
  },
  created() { },
  mounted() {
    const that = this
    this.SSSB()
    this.SYXS(1)


  },
  computed: {
    ...mapState(["map"]),
    adcode() {
      return this.map.adcode;
    },
    filteredEnterprises() {
      if (!this.searchQuery) {
        return this.enterprises;
      }
      return this.enterprises.filter(enterprise => {
        let f = enterprise.name.toLowerCase().includes(this.searchQuery.toLowerCase())

        let s = false

        if (enterprise.children != undefined) {
          for (let child of enterprise.children) {
            console.log(child.name)

            s = child.name.toLowerCase().includes(this.searchQuery.toLowerCase())
            if (s) {

              break
            }
          }
        }
        return f || s

      });
    }
  },
  data() {
    return {
      tabsDialogParams: {
        dialogVisible: false,
        openType: null,
        objItem: null,
      },
      defaultProps: {
        children: 'children',
        label: 'name',
        count: 'count'
      },
      searchQuery: '',
      enterprises: [
      ],
      LeftTitle: [...data],
      /*左侧数据*/
      IconImg1,
      IconImg2,
      IconImg3,

      OBDtotal: "",
      sssb: {},
      syxs: [],
      drsj: {},
      /*切换按钮*/
      radio1: "上一小时",
    };
  },
  props: {

  },
  methods: {
    handleNodeClick(data) {

      const regionId = data.regionId
      if (data.children != undefined || data.children != null) {
        return
      }
      this.tabsDialogParams.objItem = regionId;
      this.tabsDialogParams.dialogVisible = true;
      this.$emit('handleNodeClick', this.tabsDialogParams); // 触发自定义事件
    },
    SSSB(id) {
      enterpriseMonitoringCounts({ cId: id })
        .then((res) => {
          this.sssb = res.data;
        })
        .catch((err) => {
          console.log(err);
        });

    },
    SYXS(id) {
      getCarLastHourCountCache({ cId: id })
        .then((res) => {
          this.syxs = res.data;
          // let val1 = res.data.fuelTypes["柴油"];
          // let val2 = res.data.total;
          // let num = this.myfun.dataPercentage(val1, val2);
          // this.$set(this.syxs, "cyPercentage", num);

        })
        .catch((err) => {
          console.log(err);
        });
    },
    DRSJ(id) {
      getCarDayCountsummaryToday({ cId: id })
        .then((res) => {
          this.drsj = res.data;
          let val1 = res.data.fuelTypes["柴油"];
          let val2 = res.data.total;
          let num = this.myfun.dataPercentage(val1, val2);
          this.$set(this.drsj, "cyPercentage", num);
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  watch: {
    // adcode: {
    //   immediate: true,
    //   deep: true,
    //   handler(newValue, oldValue) {
    //     const storage = window.localStorage;
    //     let deptId = storage.deptId;
    //     this.SSSB(deptId);
    //     this.SYXS(deptId);
    //     this.DRSJ(deptId);
    //   },
    // },
  },
};
</script>

<style scoped lang="scss">
#actual {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding-top: 20px;
  position: relative;
  overflow: hidden;

  .one {
    width: 480px;
    box-sizing: border-box;
    overflow: hidden;
    margin-left: 20px;
  }

  .two {
    width: 480px;
    box-sizing: border-box;
    padding-top: 36px;
    overflow: hidden;
    margin-left: 20px;
    position: relative;
    display: flex;

    .card {
      flex: 1;
      /* 主卡片样式，嵌套在 .two 内 */
      box-shadow: 0 4px 12px rgba(10, 30, 56, 0.3);
      background: radial-gradient(ellipse at right, rgba(10, 30, 56, 0.2) 0%, rgba(10, 30, 56, 0.8) 100%);
      border-radius: 12px;
      border: none;
      box-sizing: border-box;
      height: 100%;
      display: flex;
      font-family: 'Microsoft YaHei';
      color: #FFFFFF;
      flex-direction: column;

      /* 增加内边距 */
      ::v-deep .label {
        color: #07e7f3;
        width: 100%;
        font-family: 'Microsoft YaHei';
        font-size: 14px;
      }

      ::v-deep .el-input {

        /* 输入框样式 */
        .el-input__inner {
          background: rgba(255, 255, 255, 0.05);
          border-color: rgba(50, 149, 255, 0.3);
          color: #409eff;
          height: 42px;
          border-radius: 8px;

          &::placeholder {
            color: #409eff;
          }
        }
      }

      .tree-container {
        height: 250px;
        overflow-y: auto;
        /* 与输入框的间距 */

        .custom-tree {
          /* 树状结构样式 */
          background: rgba(10, 30, 56, 0.9);
          border-radius: 8px;

          .el-tree-node {
            transition: all 0.3s ease;

            &:hover>.node-item {
              background: rgba(50, 149, 255, 0.1);
            }
          }
        }
      }
    }

    /* 按钮组样式，与 .card 同级 */
    .btn-box {
      position: absolute;
      right: 16px;
      top: 36px;
      /* 其他样式不变 */
    }
  }

  .three {
    width: 480px;
    height: 100%;
    box-sizing: border-box;
    padding-top: 36px;
    overflow: hidden;
    margin-left: 20px;
    position: relative;
    display: flex;

    .card {
      flex: 1;
      /* 主卡片样式，嵌套在 .two 内 */
      box-shadow: 0 4px 12px rgba(10, 30, 56, 0.3);
      background: radial-gradient(ellipse at right, rgba(10, 30, 56, 0.2) 0%, rgba(10, 30, 56, 0.8) 100%);
      border-radius: 12px;
      border: none;
      box-sizing: border-box;
      height: 100%;
      display: flex;
      font-family: 'Microsoft YaHei';
      color: #FFFFFF;
      flex-direction: column;

      /* 增加内边距 */
      ::v-deep .label {
        color: #07e7f3;
        width: 100%;
        font-family: 'Microsoft YaHei';
        font-size: 14px;
      }

      ::v-deep .el-input {

        /* 输入框样式 */
        .el-input__inner {
          background: rgba(255, 255, 255, 0.05);
          border-color: rgba(50, 149, 255, 0.3);
          color: #409eff;
          height: 42px;
          border-radius: 8px;

          &::placeholder {
            color: #409eff;
          }
        }
      }

      .tree-container {
        height: 250px;
        overflow-y: auto;
        /* 与输入框的间距 */

        .custom-tree {
          /* 树状结构样式 */
          background: rgba(10, 30, 56, 0.9);
          border-radius: 8px;

          .el-tree-node {
            transition: all 0.3s ease;

            &:hover>.node-item {
              background: rgba(50, 149, 255, 0.1);
            }
          }
        }
      }
    }

    /* 按钮组样式，与 .card 同级 */
    .btn-box {
      position: absolute;
      right: 16px;
      top: 36px;
      /* 其他样式不变 */
    }
  }
}
</style>
